<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

class CreateAdminRolesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('admin_roles')) {
            Schema::create('admin_roles', function (Blueprint $table) {
                $table->id();
                $table->integer('admin_id')->default(0)->comment('创建该角色组的管理员ID(专用), 0为公用角色组');
                $table->string('role_name', 32)->comment('角色规则名');
                $table->string('role_desc')->comment('简介');
                $table->enum('status', ['normal', 'ban'])->default('normal');
                $table->timestamps();
            });
            DB::statement("ALTER TABLE `admin_roles` comment '角色表'");
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('admin_roles');
    }
}
